/*
 * @Author: GKN
 * @Date: 2023-07-25 09:26:43
 * @LastEditTime: 2024-03-25 16:44:56
 * @LastEditors: GKN
 * @Description: 
 * @FilePath: \mod\src\router\index.js
 * 可以输入预定的版权声明、个性签名、空行等
 */
/*
 * @Author: GKN
 * @Date: 2023-07-25 09:26:43
 * @LastEditTime: 2023-09-14 17:28:17
 * @LastEditors: GKN
 * @Description: 
 * @FilePath: \mod\src\router\index.js
 * 可以输入预定的版权声明、个性签名、空行等
 */
import { createRouter, createWebHistory } from 'vue-router'
// import VueRouter from "vue-router";
// import Vue from "vue";
import home from '../view/home/indexHome.vue';
import special from '../view/home/special.vue';
import specialInfo from '../view/home/special_info.vue';
import village from '../view/home/village.vue';
import villageNotes from '../view/home/villageNotes.vue';
import cloudHall from '../view/home/cloudHall.vue';
import login from '../view/login/index.vue';
import register from '../view/login/register.vue';
import userView from '../view/user/index.vue';

// 文章详情
import listInfo from '../view/components/list/listInfo.vue';

import politics from '../view/politics/index.vue';
import ie from '../view/ie/index.vue';

// 案例征集
import Case from '../view/case/index.vue';
import ad1view from '../view/case/adminInnovate/index.vue';
import ad2view from '../view/case/adminInnovate/info.vue';

import MainAc from '../view/mainAc/index.vue';
import MainAcInfo from '../view/mainAc/info.vue';
import MainAcList1 from '../view/mainAc/list1.vue';
import MainAcJPiNFO from '../view/mainAc/jpInfo.vue';

import AchView from '../view/ach/index.vue';
import AchView1 from '../view/ach/a1.vue';
import AchView2 from '../view/ach/a2.vue';
import AchView3 from '../view/ach/a3.vue';
import AchView4 from '../view/ach/a4.vue';
import AchEnter1 from '../view/ach/enter/a1.vue';
import AchEnter2 from '../view/ach/enter/a2.vue';

import inn from '../view/inn/index.vue';
import innList from '../view/inn/a1.vue';
import animatedly from '../view/animatedly/list.vue';
import animatedlyListSearch from '../view/animatedly/listSearch.vue';
import animatedlyOther from '../view/animatedly/list_other.vue';
import animatedlyInfo from '../view/animatedly/info.vue';
import animatedlyInfoZt from '../view/animatedly/info_zt.vue';
import listTab from '../view/animatedly/listTab.vue';
import politicsList from '../view/politics/a1.vue';
import politicsInfo from '../view/politics/a1_s.vue';
import imptAc from '../view/imptAc/index.vue';
// 底部页面
// import footView from '../view/footView/index.vue';
import about from '../view/footView/about.vue';
import adex from '../view/footView/adex.vue';
import brand from '../view/footView/brand.vue';
import legal from '../view/footView/legal.vue';
import contact from '../view/footView/contact.vue';
// Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    component: home,
    name:'home',
    meta:{refresh:true,keepAlive: 1}
  },
  {
    path: '/login',
    component: login,
    meta: {keepAlive: 2}
  },
  {
    path:'/about',
    name:'about',
    component: about,
    meta: {keepAlive: 3}
  },
  {
    path:'/legal',
    name:'legal',
    component: legal,
    meta: {keepAlive: 3}
  },
  {
    path:'/brand',
    name:'brand',
    component: brand,
    meta: {keepAlive: 3}
  },
  {
    path:'/adex',
    name:'adex',
    component: adex,
    meta: {keepAlive: 3}
  },
  {
    path:'/contact',
    name:'contact',
    component: contact,
    meta: {keepAlive: 3}
  },
  {
    path:'/register',
    component: register,
    meta: {keepAlive: 2}
  },
  // 云展厅
  {
    path: '/cloudHall',
    name:'cloudHall',
    component: cloudHall,
    meta:{keepAlive: 1}
  },
  // 专题页
  {
    path: '/special',
    name:'special',
    component: special,
    meta:{keepAlive: 1}
  },
  // 专题详情
  {
    path: '/specialInfo',
    name:'specialInfo',
    component: specialInfo,
    meta:{keepAlive: 1}
  },
  // 乡村振兴
  {
    path: '/village',
    name:'village',
    component: village,
    meta:{keepAlive: 1}
  },
  {
    path: '/villageNotes',
    name:'villageNotes',
    component: villageNotes,
    meta:{keepAlive: 1}
  },
  {
    path: '/user',
    children:[
      {
        path:"",
        name:"user",
        component:userView,
        meta:{keepAlive: 1}
      },
    ]
  },
  {
    path: '/listInfo',
    children:[
      {
        path:"",
        name:"listInfo",
        component:listInfo,
        meta:{keepAlive: 1}
      },
    ]
  },
  {
    path: '/politics',
    children:[
      {
        path:"",
        name:"politics",
        component:politics,
        meta:{keepAlive: 1}
      },
      {
        path:"list",
        name:"politicsList",
        component:politicsList,
        meta:{keepAlive: 1}
      },
      {
        path:"info",
        name:"politicsInfo",
        component:politicsInfo,
        meta:{keepAlive: 1}
      },
    ]
  },
  {
    path:"/ie",
    children:[
      {
        path:"",
        name:"ie",
        component:ie,
        meta:{keepAlive: 1}
      },
    ]
  },
  {
    path: '/case',
    children:[
      {
        path:"",
        name:"case",
        component:Case,
        meta:{keepAlive: 1}
      },
      {
        path:"info1",
        name:"case-adminInnovate-info1",
        component:ad1view,
        meta:{keepAlive: 1}
      },
      {
        path:"info2",
        name:"case-adminInnovate-info2",
        component:ad2view,
        meta:{keepAlive: 1}
      },
    ]
  },
  {
    path: '/mainAc',
    children:[
      {
        path:"",
        name:"mainAc",
        component:MainAc,
        meta:{keepAlive: 1}
      },
      {
        path:"info",
        name:"mainAc-info",
        component:MainAcInfo,
        meta:{keepAlive: 1}
      },
      {
        path:"l1",
        name:"mainAc-list1",
        component:MainAcList1,
        meta:{keepAlive: 1}
      },
      {
        path:"jpinfo",
        name:"mainAc-jpinfo",
        component:MainAcJPiNFO,
        meta:{keepAlive: 1}
      },
    ]
  },
  {
    path: '/ach',
    children:[
      {
        path:"",
        name:"ach",
        component:AchView,
        meta:{keepAlive: 1}
      },
      {
        path:"i1",
        name:"ach-a1",
        component:AchView1,
        meta:{keepAlive: 1}
      },
      {
        path:"i2",
        name:"ach-a2",
        component:AchView2,
        meta:{keepAlive: 1}
      },
      {
        path:"i3",
        name:"ach-a3",
        component:AchView3,
        meta:{keepAlive: 1}
      },
      {
        path:"i4",
        name:"ach-a4",
        component:AchView4,
        meta:{keepAlive: 1}
      },
      {
        path:"i5",
        name:"ach-a5",
        component:AchEnter1,
        meta:{keepAlive: 1}
      },
      {
        path:"i6",
        name:"ach-a6",
        component:AchEnter2,
        meta:{keepAlive: 1}
      }
    ]
  },
  {
    path:"/imptAc",
    children:[
      {
        path:"",
        name:"imptAc",
        component:imptAc,
        meta:{keepAlive: 1}
      }
    ]
  },
  
  {
    path: '/inn',
    children:[
      {
        path:"",
        name:"inn",
        component:inn,
        meta:{keepAlive: 1}
      },
      {
        path:"list",
        name:"innList",
        component:innList,
        meta:{keepAlive: 1}
      },
    ]
  },
  {
    path:"/animatedly",
    children:[
      {
        path:"list",
        name:"animatedly",
        component:animatedly,
        meta:{keepAlive: 1}
      },
      {
        path:"listSearch",
        name:"animatedlylist",
        component:animatedlyListSearch,
        meta:{keepAlive: 1}
      },
      {
        path:"listOther",
        name:"animatedlylistother",
        component:animatedlyOther,
        meta:{keepAlive: 1}
      },
      {
        path:"info",
        name:"animatedlyInfo",
        component:animatedlyInfo,
        meta:{keepAlive: 1}
      },
      {
        path:"info_zt",
        name:"animatedlyInfoZt",
        component:animatedlyInfoZt,
        meta:{keepAlive: 1}
      },
      {
        path:"listTab",
        name:'listTab',
        component:listTab,
        meta:{keepAlive: 1}
      }
    ]
  },
  // 专题1
  {
    path: '/s1',
    children:[
      {
        path:"",
        name:"s1",
        component: () => import('@/view/specialSubject/s1/index.vue'),
        meta:{keepAlive: 1}
      },
    ]
  },
  // 专题2
  {
    path: '/s2',
    children:[
      {
        path:"",
        name:"s2",
        component: () => import('@/view/specialSubject/s2/index.vue'),
        meta:{keepAlive: 1}
      },
    ]
  },
  // 专题3
  {
    path: '/s3',
    children:[
      {
        path:"",
        name:"s3",
        component: () => import('@/view/specialSubject/s3/index.vue'),
        meta:{keepAlive: 1}
      },
    ]
  },
  {
    path: '/s4',
    children:[
      {
        path:"",
        name:"s4",
        component: () => import('@/view/specialSubject/s4/index.vue'),
        meta:{keepAlive: 1}
      },
    ]
  }
]

const router = createRouter({
  mode:'history',
  history: createWebHistory(process.env.BASE_URL),
  routes,
  scrollBehavior(to, from, saveScrollPosition) {
    return { left: 0, top: 0 };

  },
})
// 前置守卫————执行前，一般验证用户是否登入，token验证
router.beforeEach((to,from,next) => {
  if(to.meta.refresh){
    // window.location.reload()
  }
  next()
})

// 解析守卫————解析前,在导航解析完之前执行，所有的异步路由组件加载完成及组件内守卫执行之后
// 用途可以设置访问页面时，可设置不同的基础域名
router.beforeResolve((to,from,next)=> {
  // next({name:'home'})
  if(to.name == 'home'){
    localStorage.setItem( 'tabsStatus', 0 )
  }
  if(to.name == 'politics'){
    localStorage.setItem( 'tabsStatus', 1 )
  }
  if(to.name == 'ie'){
    localStorage.setItem( 'tabsStatus', 2 )
  }
  if(to.name == 'mainAc'){
    localStorage.setItem( 'tabsStatus', 3 )
  }
  if(to.name == 'case'){
    localStorage.setItem( 'tabsStatus', 4 )
  }
  if(to.name == 'imptAc'){
    localStorage.setItem( 'tabsStatus', 5 )
  }
  if(to.name == 'ach'){
    localStorage.setItem( 'tabsStatus', 6 )
  }
  if(to.name == 'inn'){
    localStorage.setItem( 'tabsStatus', 7 )
  }
  next()
  // return false
  
})

// 后置守卫————路由变化执行后，不能阻止页面跳转
router.afterEach((to,from,failure) => {
  
})
export default router;
